﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.Framework.Noebe.Orm
{
    class StringHelper
    {
        private static Int64 formervalue = Int64.MinValue;


        /// <summary>
        /// 默认的id 如果对框架采用Singleton<>，那么会修改这个值
        /// </summary>
        public const string global_framework_id = "pixysoft.framework.noebe.orm";



        public const int default_column_string_length = 50;

        public const int default_pk_ranlength = 2;


        public const string COL_HOLDER = "@COL_HOLDER";

        public const string CONS_HOLDER = "@CONS_HOLDER";



        public const string ORM_GROUPCODE = "ORM_GROUPCODE";

        public const string ORM_CREATEDATE = "ORM_CREATEDATE";

        public const string ORM_MODIDATE = "ORM_MODIDATE";


        public static Int64 GetNullPrimaryKey()
        {
            return Int64.MaxValue;
        }

        public static Int64 CreatePrimaryKey()
        {
            return CreatePrimaryKey(1);
        }

        public static Int64 CreatePrimaryKey(int count)
        {
            do
            {
                Int64 currentvalue = Pixysoft.Tools.GlobalTimer.Instance.GetUniqueSequence(StringHelper.default_pk_ranlength);

                if (currentvalue == formervalue)
                    continue;

                formervalue = currentvalue + count - 1;//上次的取值

                return currentvalue;

            } while (true);
        }

        public static Int64 CreatePositionIndex()
        {
            return Pixysoft.Tools.GlobalTimer.Instance.GetUniqueSequence();
        }
    }
}
